import 'dart:async';

import 'package:flutter/material.dart';
import 'package:hkzf_flutter/routes.dart';
import 'package:hkzf_flutter/scoped_model/auth_model.dart';
import 'package:hkzf_flutter/utils/scoped_model_helper.dart';

class LoadingPage extends StatefulWidget {
  const LoadingPage({super.key});

  @override
  State<LoadingPage> createState() => _LoadingPageState();
}

class _LoadingPageState extends State<LoadingPage> {
  @override
  void initState() {
    // 延迟3秒后跳转到首页页面
    Timer(const Duration(seconds: 3), () {
      Navigator.of(context).pushReplacementNamed(Routes.layout);
    });
    // 延迟初始化登录的权限信息
    Timer.run(() {
      ScopedModelHelper.getModel<AuthModel>(context).initApp(context);
    });

    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return Container(
      decoration:const BoxDecoration(
        image: DecorationImage(
          image: AssetImage('static/images/loading.jpg'),
          fit: BoxFit.cover,
        ),
      ),
    );
  }
}